import {Form} from '@/components/layout/form/form';
import {DATE, DATETIMES, FILE, SELECT, TEXT, TEXTAREA} from '@/utils/enums/type-enums';
import Storage from '@/utils/storage';
import {ACCESS_TOKEN_KEY} from '@/utils/enums/cache-enum';

export const deviceForm: Form[] = [{
  label: null, card: [
    {
      label: '设备名称',
      name: 'deviceName',
      type: TEXT,
      width: 100,
      span: 5,
      placeholder: '输入设备名称'
    },
    {
      label: '设备编码',
      name: 'deviceCode',
      type: TEXT,
      width: 100,
      span: 5,
      placeholder: '设备编码'
    },
    {
      label: 'SN编码',
      name: 'sn',
      type: TEXT,
      width: 100,
      span: 5,
      placeholder: 'SN编码'
    },
    {
      label: '设备类型',
      name: 'constCode',
      type: SELECT,
      width: 100,
      span: 4,
      placeholder: '设备类型',
      options: []
    },
    {
      label: '设备归属',
      name: 'organizationId',
      type: SELECT,
      width: 100,
      span: 4,
      placeholder: '设备归属',
      options: []
    }
  ]
}];

export const deviceAddForm: Form[] = [
  {
    label: null, card: [
      {
        label: '设备归属',
        name: 'organizationId',
        type: SELECT,
        width: 120,
        span: 6,
        placeholder: '设备归属',
        options: []
      },
      {line: true},
      {
        label: '产品',
        name: 'specId',
        type: SELECT,
        width: 120,
        span: 6,
        placeholder: '产品',
        options: []
      },
      {
        label: '设备类型',
        name: 'constCode',
        type: SELECT,
        width: 120,
        span: 6,
        placeholder: '设备类型',
        options: []
      },
      {
        label: '设备形态',
        name: 'formCode',
        type: SELECT,
        width: 120,
        span: 6,
        placeholder: '设备形态',
        options: []
      },
      {line: true},
      {
        label: '设备名称',
        name: 'deviceName',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '输入设备名称'
      },
      {
        label: '设备编码',
        name: 'deviceCode',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '设备编码'
      },
      {line: true},
      {
        label: '设备状态',
        name: 'status',
        type: SELECT,
        width: 120,
        span: 6,
        options: [
          {label: '未开通', value: 0},
          {label: '已开通', value: 1},
          {label: '已停用', value: 2},
          {label: '已回收', value: 3},
          {label: '已报废', value: 4}
        ],
        placeholder: '设备状态'
      },
      {line: true},
      {
        label: '设备通信编码',
        name: 'connectCode',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '输入设备名称'
      },
      {
        label: 'SN编码',
        name: 'sn',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: 'SN编码'
      },
      {
        label: '硬件版本',
        name: 'hardwareVersion',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '硬件版本'
      },
      {line: true},
      {
        label: '软件版本',
        name: 'softwareVersion',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '硬件版本'
      },
      {
        label: '会话密钥',
        name: 'sessionKey',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '会话密钥'
      },
      {
        label: '加密向量',
        name: 'ivParameter',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '加密向量'
      },
      {line: true},
      {
        label: '长（单位cm）',
        name: 'longs',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '长（单位cm）'
      },
      {
        label: '宽（单位cm）',
        name: 'wide',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '宽（单位cm）'
      },
      {
        label: '高（单位cm）',
        name: 'high',
        type: TEXT,
        width: 120,
        span: 6,
        placeholder: '高（单位cm）'
      },
      {line: true},
      {
        label: '支持功能',
        name: 'functions',
        width: 120,
        span: 6,
        placeholder: '支持功能'
      },
      {line: true},
      {
        label: '备注',
        name: 'remark',
        type: TEXTAREA,
        width: 120,
        style: {width: '400px'},
        span: 24,
        placeholder: '高（单位cm）'
      },
    ]
  }
]

export const deviceDetailsForm: Form[] = [
  {
    label: null, card: [
      {
        label: '设备归属',
        name: 'organizationName',
        width: 120,
        span: 6,
        placeholder: '设备归属',
        options: []
      },
      {line: true},
      {
        label: '产品',
        name: 'specName',
        width: 120,
        span: 6,
        placeholder: '产品',
        options: []
      },
      {
        label: '设备类型',
        name: 'constName',
        width: 120,
        span: 6,
        placeholder: '设备类型',
        options: []
      },
      {
        label: '设备形态',
        name: 'formName',
        width: 120,
        span: 6,
        placeholder: '设备形态',
        options: []
      },
      {line: true},
      {
        label: '设备名称',
        name: 'deviceName',
        width: 120,
        span: 6,
        placeholder: '输入设备名称'
      },
      {
        label: '设备编码',
        name: 'deviceCode',
        width: 120,
        span: 6,
        placeholder: '设备编码'
      },
      {line: true},
      {
        label: '设备状态',
        name: 'status',
        width: 120,
        span: 6,
        options: [
          {label: '未开通', value: 0},
          {label: '已开通', value: 1},
          {label: '已停用', value: 2},
          {label: '已回收', value: 3},
          {label: '已报废', value: 4}
        ],
        placeholder: '设备状态'
      },
      {line: true},
      {
        label: '设备通信编码',
        name: 'connectCode',
        width: 120,
        span: 6,
        placeholder: '输入设备名称'
      },
      {
        label: 'SN编码',
        name: 'sn',
        width: 120,
        span: 6,
        placeholder: 'SN编码'
      },
      {
        label: '硬件版本',
        name: 'hardwareVersion',
        width: 120,
        span: 6,
        placeholder: '硬件版本'
      },
      {line: true},
      {
        label: '软件版本',
        name: 'softwareVersion',
        width: 120,
        span: 6,
        placeholder: '硬件版本'
      },
      {
        label: '会话密钥',
        name: 'sessionKey',
        width: 120,
        span: 6,
        placeholder: '会话密钥'
      },
      {
        label: '加密向量',
        name: 'ivParameter',
        width: 120,
        span: 6,
        placeholder: '加密向量'
      },
      {line: true},
      {
        label: '长（单位cm）',
        name: 'longs',
        width: 120,
        span: 6,
        placeholder: '长（单位cm）'
      },
      {
        label: '宽（单位cm）',
        name: 'wide',
        width: 120,
        span: 6,
        placeholder: '宽（单位cm）'
      },
      {
        label: '高（单位cm）',
        name: 'high',
        width: 120,
        span: 6,
        placeholder: '高（单位cm）'
      },
      {line: true},
      {
        label: '支持功能',
        name: 'functions',
        width: 120,
        span: 6,
        placeholder: '支持功能'
      },
      {line: true},
      {
        label: '备注',
        name: 'remark',
        width: 120,
        style: {width: '400px'},
        span: 24,
        placeholder: '高（单位cm）'
      },
    ]
  }
]

export const deviceRules = {
  specId: [{required: true, message: '产品不能为空', trigger: 'blur'}],
  constCode: [{required: true, message: '设备类型不能为空', trigger: 'blur'}],
  deviceName: [{required: true, message: '设备名称不能为空', trigger: 'blur'}],
  deviceCode: [{required: true, message: '设备编码不能为空', trigger: 'blur'}],
  status: [{required: true, message: '设备状态不能为空', trigger: 'blur'}],
}

export const deviceRepairRecordForm: Form[] = [{
  label: null, card: [
    {
      type: SELECT,
      label: '类型',
      name: 'repairType',
      span: 24,
      options: [{value: 0, label: '维修'}, {value: 1, label: '报废'}]
    },
    {
      type: DATE,
      label: '维修开始时间',
      name: 'addTime',
      span: 24
    },
    {
      type: DATE,
      label: '维修结束时间',
      name: 'editTime',
      span: 24
    },
    {
      type: FILE,
      label: '上传维修单',
      name: 'repairDoc',
      action: '/bms/upload/file',
      headers: {
        token: Storage.get(ACCESS_TOKEN_KEY)
      },
      span: 24
    },
    {
      type: TEXTAREA,
      label: '维修说明',
      name: 'remark',
      span: 24,
      style: {width: '400px'}
    }
  ]
}]

export const deviceScrapRecordForm: Form[] = [{
  label: null, card: [
    {
      type: SELECT,
      label: '类型',
      name: 'repairType',
      span: 24,
      options: [{value: 0, label: '维修'}, {value: 1, label: '报废'}]
    },
    {
      type: DATE,
      label: '报废时间',
      name: 'addTime',
      span: 24
    },
    {
      type: FILE,
      label: '上传检修报告',
      name: 'repairDoc',
      action: '/bms/upload/file',
      headers: {
        token: Storage.get(ACCESS_TOKEN_KEY)
      },
      span: 24
    }
  ]
}]

export const deviceRecordRules = {
  repairType: [{required: true, message: '类型不能为空', trigger: 'blur'}],
  addTime: [{required: true, message: '不能为空', trigger: 'blur'}],
  editTime: [{required: true, message: '不能为空', trigger: 'blur'}],
}

/**
 * 设备流转表单
 */
export const deviceReplaceForm: Form[] = [{
  label: null, card: [
    {
      label: '原机构',
      name: 'sourceOrganizationName',
      span: 24
    },
    {
      type: SELECT,
      label: '流转机构',
      name: 'targetOrganizationId',
      span: 24
    },
    {
      type: TEXTAREA,
      label: '备注',
      name: 'remark',
      span: 24,
      style: {width: '400px'}
    }
  ]
}]

export const deviceReplaceRules = {
  targetOrganizationId: [{required: true, message: '流转机构不能为空', trigger: 'blur'}],
}
export const historyForm: Form[] = [
  {
    label: null, card: [
      {
        type: SELECT,
        label: '消息类型',
        name: 'messageType',
        options: [
          {value: '', label: '全部'},
          {value: '0', label: '数据包开始(0)'},
          {value: '1', label: '注册包(1)'},
          {value: '2', label: '数据包（不回复）(2)'},
          {value: '3', label: '数据包结束(3)'},
          {value: '4', label: '心跳包(4)'},
          {value: '5', label: '原始数据包（不回复）(5)'},
          {value: '6', label: '反馈硬件状态（不回复）(6)'},
          {value: '7', label: '反馈血压(7)'},
          {value: '8', label: '反馈体温(8)'},
          {value: '9', label: 'RTC校时(9)'},
          {value: '10', label: '报警信息(10)'},
          {value: '11', label: '查询设置信息(11)'},
          {value: '12', label: '设置即时温度控制(12)'},
          {value: '13', label: '数据包超长结束(13)'},
          {value: '14', label: '预约加热(14)'},
          {value: '15', label: '设置血压体温定时（间隔）测量(15)'},
          {value: '16', label: '血压定点测量(16)'},
          {value: '17', label: '血压定点测量(17)'},
          {value: '18', label: '设置报警阈值(18)'},
          {value: '19', label: '温度总开关(19)'},
          {value: '20', label: '设置血氧血压体温蓝牙连接(20)'},
          {value: '21', label: '反馈血氧血压体温蓝牙数据(21)'},
          {value: '22', label: '数据包（需回复）(22)'},
          {value: '23', label: '实时数据包(23)'},
          {value: '24', label: '在线升级指令(24)'},
          {value: '25', label: '在线升级下载状态(25)'},
          {value: '26', label: 'ECG数据包(26)'},
          {value: '0xFF', label: '在线升级数据包(0xFF)'}
        ]
      },
      {
        type: DATETIMES,
        label: '开始时间',
        name: 'messageTimeBegin'
      },
      {
        type: DATETIMES,
        label: '结束时间',
        name: 'messageTimeEnd'
      }
    ]
  }
]
export const historyRules = {
  messageTimeBegin: [{required: true, message: '开始时间不能为空', trigger: 'blur'}],
}